<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-08-16 16:47
 *
 * Version: 2.0
 */

namespace App\Modules\Employee\Transformers;

use League\Fractal\TransformerAbstract;

class GetStoreRestListTransformer extends TransformerAbstract
{
	private $list;
	public function __construct($list)
	{
		$this->list = $list;
	}

	public function transform(){
		$result = null;
		if(!$this->list->isEmpty()){
			foreach ($this->list as $v){
				$newList[date('j',$v->plan_date)][]= empty($v->user) ? : $v->user->nick;
			}
			foreach ($newList as $k => $j){
				$result[] = [
					'date' => $k,
					'user' => $j
				];
			}
		}
		return $result;
	}

}
